﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace TCSilverlight.Web
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "WCFService" in code, svc and config file together.
    public class WCFService : IWCFService
    {
        public List<tblProduct> GeTblProducts()
        {
            ProductsDataContext pdata = new ProductsDataContext();
            var listProducts = from products in pdata.tblProducts
                               select products;
            
            return listProducts.ToList();



        }

        public List<DataItem> GetTestImages()
        {
            List<DataItem> listDataItem = new List<DataItem>();

            DataItem tempDataItem = new DataItem();
            tempDataItem.ImageSourceId = new Uri("../Images/CoverFlow/Paris_1.jpg", UriKind.Relative);
            //tempDataItem.ImageSourceId = new Uri("/Images/CoverFlow/Paris_1.jpg", UriKind.Relative);
            tempDataItem.ProductDescription = "Paris is the most popular touris landmarks.";
            tempDataItem.ProductName = "Paris";
            tempDataItem.ProductPrice = 900.00;
            listDataItem.Add(tempDataItem);

            tempDataItem = new DataItem();
            tempDataItem.ImageSourceId = new Uri("../Images/CoverFlow/Dubai_8.jpg", UriKind.Relative);
            tempDataItem.ProductDescription = "toi van la toi";
            tempDataItem.ProductName = "Paris";
            tempDataItem.ProductPrice = 1000.00;
            listDataItem.Add(tempDataItem);

            return listDataItem;
        }
        //public void DoWork()
        //{
        //}

        public class DataItem
        {
            private Uri imageSourceId;
            private string productName;
            private string productDescription;
            private double productPrice;

            public Uri ImageSourceId
            {
                get { return imageSourceId; }
                set { imageSourceId = value; }
            }

            public string ProductName
            {
                get { return productName; }
                set { productName = value; }
            }

            public string ProductDescription
            {
                get { return productDescription; }
                set { productDescription = value; }
            }

            public double ProductPrice
            {
                get { return productPrice; }
                set { productPrice = value; }
            }
        }
    }
}
